﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TreeNodeData : TreePartData
{
    public int Length;

    public bool IsLeaf
    {
        get { return Sons == null || Sons.Count == 0; }
    }

    public int GetValue()
    {
        if (IsLeaf)
        {
            return Const.AirOrginValue + (Const.DirtStar - GridPos.PosY - 1) * Const.AirAddValue;
        }
        else
        {
            return 0;
        }
    }

    public TreeNodeData( GridData gridPos, TreePartData root) : base(TreePartType.Node, gridPos, root)
    {
        if (root.Type == TreePartType.Node)
        {
            Length = (root as TreeNodeData).Length + 1;
        }
        else
        {
            Length = 1;
        }
    }
}
